<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加绑定人</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        body {
            background-color: #f1f1f1;
            padding: 1rem;
        }
        
        .box {
            padding: 1rem;
            background-color: #fff;
        }
        
        p {
            margin-bottom: 1rem;
            width: 100%;
        }
        
        input {
            height: 25px;
            border: none;
            border: 1px solid #ccc;
            outline: none;
            padding-left: 5px;
        }
        
        .box p span {
            display: inline-block;
            width: 30%;
            text-align: right;
            margin-right: 10px;
        }
        
        .box p:nth-last-child(1) {
            display: flex;
            justify-content: space-evenly;
        }
        
        button {
            width: 30%;
            height: 30px;
            border: none;
            border: 1px solid #ccc;
            background-color: #3B97FD;
            color: #fff;
        }
        
        .show {
            display: none;
        }
    </style>
</head>

<body>
    <div class="box">
        <p><span>身份证号:</span> <input type="text" name="identityNo" id="identityNo"></p>
        <p><span>手机号:</span> <input type="text" name="tel" id="tel"></p>
        <p><span>绑定者关系:</span> <select id="skills" name="skills">
            <option value="本人">本人</option>
			<option value="父亲">父亲</option>
			<option value="母亲">母亲</option>
			<option value="兄弟">兄弟</option>
            <option value="其它">其它</option>
		</select></p>
        <p class="show"><span>其它</span> <input type="text" name="relationship" id="relationship" placeholder="请输入与绑定者的关系"></p>
        <p>
            <span>姓名:</span> <input type="text" name="fullName" id="fullName">
        </p>
        <p><button onclick="getGo()">返回绑定</button> <button class="addBinding">确认添加</button></p>
    </div>
    <div class="show">

    </div>
    <script src="/js/jquery-3.6.0.min.js"></script>
    <script src="/js/config.js"></script>
    <script>
        var relationship
        $('#skills').blur(function() {
            if ($('#skills').val() === '其它') {
                $('.show').css("display", "block")
            }
        })
        $('.addBinding').click(function() {
            if ($('#relationship').val() === '') {
                relationship = $('#skills').val();
            } else {
                relationship = $('#relationship').val()
            }
            var settings = {
                "url": "http://58.210.112.60:38102/Wechat/Api/LinkArchive",
                "method": "POST",
                "timeout": 0,
                "headers": {
                    "Authorization": `${Authorization}`,
                    "Content-Type": "application/json",
                    "Accept": "*/*",
                },
                "data": JSON.stringify({
                    "username": theRequest.username,
                    "identityNo": $('#identityNo').val(),
                    "fullName": $('#fullName').val(),
                    "tel": $('#tel').val(),
                    "relationship": relationship
                }),
            };

            $.ajax(settings).done(function(response) {
                if (response.code == 200) {
                    window.location.href = `bindinglist?username=${theRequest.username}&Authorization=${Authorization}`
                }
            });

        })


        function getGo() {
            window.history.go(-1)
        }
    </script>
</body>

</html>